/*
 * Copyright 2010 - Jeremie Brebec
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.jb.ui.chat.client;

import java.io.Serializable;
import java.util.Date;

import org.jb.notification.client.Notification;

public class ChatMessage implements Serializable, Notification {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8170434153433623909L;
	private String user;
	private Date date;
	private long checkpoint;
	private String message;
	
	/**
	 * @param user the user to set
	 */
	public void setUser(String user) {
		this.user = user;
	}
	/**
	 * @return the user
	 */
	public String getUser() {
		return user;
	}
	/**
	 * @param date the date to set
	 */
	public void setDate(Date date) {
		this.date = date;
	}
	/**
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}
	/**
	 * @param message the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}
	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}
	
	/**
	 * 
	 * @return
	 */
	public boolean isSystem() {
		return "*".equals( user );
	}
	
	/**
	 * 
	 */
	public void setSystem() {
		user = "*";
	}
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("<");
		sb.append(user);
		sb.append("> ");
		sb.append( message );
		return sb.toString();
	}
	/**
	 * @param checkpoint the checkpoint to set
	 */
	public void setCheckpoint(long checkpoint) {
		this.checkpoint = checkpoint;
	}
	/**
	 * @return the checkpoint
	 */
	public long getCheckpoint() {
		return checkpoint;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.jb.coinche.client.notify.Notification#getType()
	 */
	@Override
	public String getType() {
		return "message";
	}
	
	
	
}
